package base.IO流;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class 拷贝 {
    static FileInputStream fis;
    static FileOutputStream fos;

    public static void main(String[] args) throws IOException {
        long l1 = System.currentTimeMillis();
        multiple();
        System.out.println(System.currentTimeMillis()-l1);

        long l2 = System.currentTimeMillis();
        single();
        System.out.println(System.currentTimeMillis()-l2);
    }

    public static void multiple() throws IOException {
        newFile();
        int len;
        byte[] bytes = new byte[1024 * 1024 * 2];
        while ((len = fis.read(bytes)) != -1){
            fos.write(bytes,0,len);
        }
        close();
    }

    public static void single() throws IOException {
        newFile();
        int i;
        while((i=fis.read()) != -1){
            fos.write(i);
        }
        close();
    }

    public static void newFile() throws FileNotFoundException {
        fis = new FileInputStream("D:\\微信图片\\【哲风壁纸】孤独摇滚-波奇酱 (1).png");
        fos = new FileOutputStream(".\\src\\base\\IO流\\pqj.png");
    }
    public static void close() throws IOException {
        fos.close();
        fis.close();
    }
}
